<template>
	<div class="app">
		<h2>我是App</h2>
		<h3 v-if="wanju">我收到了儿子给的玩具：{{wanju}}</h3>
		<Child ref="haizi"/>
	</div>
</template>

<script>
	import Child from './components/Child.vue'

	export default {
		name:'App',
		components:{Child},
		data() {
			return {
				wanju:''
			}
		},
		methods: {
			getToy(t){
				console.log('test调用了',t)
				this.wanju = t
			}
		},
		mounted() {
			this.$refs.haizi.$on('send-toy',this.getToy)
		},
	}
</script>

<style>
	.app{
		background-color: gray;
		padding: 20px;
	}
</style>